<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="postList">
      <el-table-column width="70" type="index" label="序号" align="center" />
      <el-table-column label="车站编码" align="center" prop="globalcode" />
      <el-table-column label="车站名称" align="center" prop="stationName" />
      <el-table-column label="自助机编号" align="center" prop="machinecode" />
      <el-table-column label="报错时间" align="center" prop="updatetime">
        <template slot-scope="scope">
          <span>{{ newDate(scope.row.updatetime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="错误信息"
        align="center"
        prop="errormsg"
        width="500"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            style="color:red"
            @click="getClear(scope.row)"
            v-hasPermi="['operationLog:selfHelpErro:edit']"
            >清除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageIndex"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { ATMTicket, cleanError } from "@/api/operationLog/selfHelpErro";
import utils from "../../js/index";

export default {
  name: "SelfHelpErro",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态数据字典
      statusOptions: [],
      //详情弹出框
      particulars: false,
      //自助机配置弹出框
      configuration: false,
      allocation: {
        machinecode: "",
        qph: "",
        zph: "",
        dqph: ""
      },
      // 查询参数
      queryParams: {
        pageIndex: 1,
        pageSize: 10,
        errormsg: undefined,
        machinecode: undefined
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询自助机报错列表 */
    getList() {
      this.loading = true;
      ATMTicket(this.queryParams).then(response => {
        this.postList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 格式化时间
    newDate(date) {
      return utils.utils.NewDate(date);
    },
    getClear(row) {
      // console.log({ machinecode: row.machinecode, id: row.id });
      cleanError({ machinecode: row.machinecode, id: row.id }).then(
        response => {
          if (response.code == 200) {
            this.getList();
          }
        }
      );
    }
  }
};
</script>
